<template>
  <div>
    <div class="top-panel__box">
      <el-form :model="dataForm" ref="dataForm" inline size="small" onsubmit="return false">
        <el-form-item>
          <el-input placeholder="搜索机构名称或机构代码" v-model="dataForm.freeCondition" maxlength="30" clearable />
        </el-form-item>
        <el-form-item>
          <el-input placeholder="受理人" v-model="dataForm.acceptorName" maxlength="30" clearable />
        </el-form-item>
        <el-form-item>
          <el-date-picker type="date" value-format="yyyy-MM-dd" v-model="dataForm.beginTime" style="width:220px" placeholder="跟进时间起" />
          <span>-</span>
          <el-date-picker type="date" v-model="dataForm.createTime" value-format="yyyy-MM-dd" style="width:220px" placeholder="跟进时间止" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getList(1)">
            <fa-icon class="fa-search" />查询</el-button>
          <el-button type="primary">
            <fa-icon class="fa-download" />导出</el-button>
          <reset-button :dataForm.sync="dataForm" :fixedData="{pageNum: 1, pageSize: 10}" />
        </el-form-item>
      </el-form>
    </div>
    <el-row class="table-top">
      <el-table :data="dataList" v-loading="tableLoading" tooltip-effect="light" class="tc-table" size="small">
        <el-table-column type="index" width="55" fixed="left" label="序号"></el-table-column>
        <template v-for="(column, index) in TEAM_HEAD_LIST">
          <el-table-column :prop="column.prop" :label="column.label" :key="index" :width="column.width" :show-overflow-tooltip="true" />
        </template>
      </el-table>
      <el-row class="pagination-top">
        <pagination :pageNum.sync="dataForm.pageNum" :curSizes.sync="dataForm.pageSize" :total="total" @getList="getList" />
      </el-row>
    </el-row>
  </div>
</template>

<script>
import api from '../api'
import { CONSTANT_OBJ } from '@/utils/constant'
import { TEAM_HEAD_LIST } from '../js/contant.js'
export default {
  data () {
    return {
      TEAM_HEAD_LIST,
      tableLoading: false,
      dataForm: {
        freeCondition: '',
        acceptorName: '',
        beginTime: '',
        endTime: '',
        pageNum: 1,
        pageSize: 10
      },
      dataList: [],
      products: [
        { productId: '1', productName: '即享金', productNo: 101 },
        { productId: '2', productName: '即享贷', productNo: 102 }
      ],
      productNoList: [],
      total: 0
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    // 查询列表
    getList (val) {
      this.dataForm.pageNum = val || this.dataForm.pageNum
      this.tableLoading = true
      api.postQueryFollowData(this.dataForm).then(res => {
        const { responseCode, data } = res
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          this.dataList = data.list || []
          this.total = parseInt(data.total) || 0
        }
      }).finally(() => {
        this.tableLoading = false
      })
    }
  }
}
</script>
